<?php
namespace app\finance\model;

use think\Model;
use think\Db;
class SystemBalanceLog extends Model
{
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 是否有效 1=有效，2=无效
    protected $insert = ['is_effective' => 1];
    // 自动写入时间戳
    protected $autoWriteTimestamp = true;
    public function getUserNameAttr($value)
    {
        $username = Db::name('user')->where('id',$value)->value('nick');
        return $username;
    }
    public function getTypeTextAttr($value,$data)
    {
        $type = [
            0 => '期初数据',
            1 => '项目收入',
            2 => '产品收入',
            3 => '充值会员卡收入',
            4 => '报销单支出',
            5 => '供应商充值支出',
            6 => '银行转出',
            7 => '银行转入',
            8 => '充值疗程卡',
            9 => '退卡支出',
            10 => '退款支出',
            11 => '退产品支出',
            12 => '其他支出',
            13 => '其他收入',
        ];
        return $type[$data['type']];
    }

    public function getAccountNameAttr($value)
    {
        $name = Db::name('account')->where('id', $value)->value('name');
        return $name;
    }
}
